package service;

import dao.implDao.FriendsDao;
import dao.implDao.GiftsDao;
import dao.implDao.UserDao;
import model.Gift;
import model.User;

import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

/**
 * Created with  IDEA.
 * User: Ѱ
 * Date: 20.07.14
 * Time: 11:04
 */
public class UserManager {
    private UserDao userDao;
    private GiftsDao giftsDao;
    private FriendsDao friendsDao;


    public UserManager() {
        friendsDao = new FriendsDao();
        userDao = new UserDao();
        giftsDao = new GiftsDao();
    }

    /**
     * Используем методы из DAO для User
     */
    public List<User> getAllUser() throws SQLException {
        return userDao.getAllUsers();
    }

    public void updateUser(User user) throws SQLException {
        userDao.updateUser(user);
    }

    public void addUser(User user) throws SQLException {
        userDao.addUser(user);
    }

    public void deleteUser(User user) throws SQLException {
        userDao.deleteUser(user);
    }

    public User getById(long id) throws SQLException {
        return userDao.getById(id);
    }

    /**
     * Используем для подарков
     */
    public void addGift(Gift gift) throws SQLException {
        giftsDao.add(gift);
    }

    public List<Gift> getAllGift() throws SQLException {
        return giftsDao.getAll();
    }

    public Gift getGiftById(long id) throws SQLException {
        return giftsDao.getGiftById(id);
    }

    public void updateGift(Gift gift) throws SQLException {
        giftsDao.update(gift);
    }

    public void deleteGift(Gift gift) throws SQLException {
        giftsDao.delete(gift);
    }

    public void addFriend(User user, User friend) throws SQLException {
        friendsDao.addFriend(user, friend);
    }

    public void deleteFriend(User user, User friend)throws SQLException{
        friendsDao.deleteFriend(user,friend);
    }

    public void addGiftByUser(User user, Gift gift) throws SQLException {
        friendsDao.addGifts(user, gift);
    }

}
